package com.baibei.ebec.quotation.converter;

import android.text.TextUtils;

import com.baibei.ebec.quotation.AppQuotationFilter;
import com.baibei.model.TradeWebSocketInfo;
import com.baibei.quotation.IActionDispatch;
import com.baibei.quotation.QuotationFilter;
import com.google.gson.Gson;

/**
 * 交易建仓
 * Created by ChenRui on 2017/8/15 0015 19:22.
 */
public class TradeResponseConverter implements IActionDispatch<TradeWebSocketInfo> {
    private final Gson mGson = new Gson();

    @Override
    public TradeWebSocketInfo convert(String json) throws Exception {
        return mGson.fromJson(json, TradeWebSocketInfo.class);
    }

    @Override
    public boolean handleAction(String action) {
        return TextUtils.equals(action, AppQuotationFilter.ACTION_TRADE_CLOSED) || TextUtils.equals(action, AppQuotationFilter.ACTION_TRADE_CREATED);
    }

    @Override
    public boolean dispatch(QuotationFilter quotationFilter, Object o) {
        return true;
    }

    @Override
    public boolean canCache() {
        return false;
    }
}
